<?php

/**
 * This is the model class for table "admintb".
 *
 * The followings are the available columns in table 'admintb':
 * @property integer $id_admin
 * @property string $username
 * @property string $password
 * @property string $email
 * @property string $phone
 * @property string $homePhone
 * @property string $LastActive
 * @property string $permission
 * @property string $ActivationKey
 * @property string $isBlock
 * @property string $dateCreated
 * @property string $userCreated
 * @property string $dateModified
 * @property string $userModified
 */
class Admintb extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Admintb the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'admintb';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('username, email, phone', 'required'),
			array('username, password, email, permission, userCreated, userModified', 'length', 'max'=>160),
			array('phone, homePhone', 'length', 'max'=>25),
			array('isBlock', 'length', 'max'=>1),
			array('LastActive, ActivationKey, dateCreated, dateModified', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_admin, username, password, email, phone, homePhone, LastActive, permission, ActivationKey, isBlock, dateCreated, userCreated, dateModified, userModified', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_admin' => 'Id Admin',
			'username' => 'Username',
			'password' => 'Password',
			'email' => 'Email',
			'phone' => 'Phone',
			'homePhone' => 'Home Phone',
			'LastActive' => 'Last Active',
			'permission' => 'Permission',
			'ActivationKey' => 'Activation Key',
			'isBlock' => 'Is Block',
			'dateCreated' => 'Date Created',
			'userCreated' => 'User Created',
			'dateModified' => 'Date Modified',
			'userModified' => 'User Modified',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_admin',$this->id_admin);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('homePhone',$this->homePhone,true);
		$criteria->compare('LastActive',$this->LastActive,true);
		$criteria->compare('permission',$this->permission,true);
		$criteria->compare('ActivationKey',$this->ActivationKey,true);
		$criteria->compare('isBlock',$this->isBlock,true);
		$criteria->compare('dateCreated',$this->dateCreated,true);
		$criteria->compare('userCreated',$this->userCreated,true);
		$criteria->compare('dateModified',$this->dateModified,true);
		$criteria->compare('userModified',$this->userModified,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}